<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class peopleModel extends Model {
    //protected $_idPeople;
    protected $_displayname;
    protected $_linkProfile;
    protected $_username;
    protected $_sns;
   
    public function setDisplayName($name) {
        $this->_displayname = $name;
    }
    
    public function setLinkProfile($link) {
        $this->_linkProfile = $link;
    }
    
    public function setUsername($usr) {
        $this->_username = $usr;
    }
    
    public function setSns($sns) {
        $this->_sns = $sns;
    }

    public function getDisplayName() {
        return $this->_displayname;
    }
    
    public function getLinkProfile() {
        return $this->_linkProfile;
    }
    
    public function getUsername() {
        return $this->_username;
    }
    
    public function getSns() {
        return $this->_sns;
    }
    
    public function storePeopleToDB() {
        $sql = "INSERT INTO people
			(username, link_profile, sns, display_name)
			VALUES
			(?, ?, ?, ?
			 )";

        $data = array($this->_username, $this->_linkProfile, $this->_sns, $this->_displayname);
        $sth = $this->_db->prepare($sql);
        return $sth->execute($data);
    }
    
    public function getPeoplebByUsername($username) {
        $sql = "SELECT *	
                    FROM people 
                    WHERE username = '$username'
                    ";

        $this->_setSql($sql);
        $people = $this->getRow();
        if (empty($people)) {
            return false;
        }
        else
            return $people;
    }
    
    public function getDisplayNameById($id) {
        $sql = "SELECT display_name
                    FROM people 
                    WHERE idPeople = '$id'
                    ";

        $this->_setSql($sql);
        $people = $this->getRow();
        if (empty($people)) {
            return false;
        }
        else
            return $people;
    }
    
    public function updateDisplayNameByUsernameId($username_id, $display_name) {
        $sql = "UPDATE people
                SET display_name = '$display_name'
                WHERE username = '$username_id'
                    ";

        $sth = $this->_db->prepare($sql);
        return $sth->execute();
    }
    
    public function storeFacebookInfoToDb() {
        
    }
}
?>
